package com.speechb.modules.utils;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

/**
 * 服务器参数配置文件获取
 * @author : llj
 * @version :2.1.0
 * @date : 2019/7/16 19:49
 */
@PropertySource("classpath:config/web-config.yml")
@Configuration
public class Global implements EnvironmentAware {
    @Value("${adminRoot}")
    String adminRootPath;
    private static Environment environment;

    /**
     * 获取参数配置文件的值
     * @param key
     * @return
     */
    public static String getProperty(String key) {
        if(StringUtils.isEmpty(key)) {
            return "";
        }
        return environment.getProperty(key);
    }

    @Override
    public void setEnvironment(Environment environment) {
        environment = environment;
    }
}
